package com.yetm.springbootdemo.websocket;

import com.alibaba.fastjson.JSONObject;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
import java.util.HashMap;

/**
 * websocket编码
 */
public class ServerEncoder implements Encoder.Text<HashMap> {
    @Override
    public String encode(HashMap hashMap) throws EncodeException {
        return JSONObject.toJSONString(hashMap);
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}
